package com.aaa.controller;

import com.aaa.service.F_TiXiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/tixi")
public class F_TiXi {
    @Autowired
    F_TiXiService service;

    /**
     * 查询所有
     * @param map
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object List(@RequestBody Map map){
        System.out.println(map);
        List<Map> data = service.selectList(map);
        //List<Map> data2 = service.getYear();
        Integer total = service.getCount(map);

        Map zmap = new HashMap();
        zmap.put("data",data);
      //  zmap.put("options",data2);
        zmap.put("total",total);
        System.out.println(zmap);
        return zmap;
    }

    /**
     * 获取年份
     * （不用了）
     * @return
     */
  @RequestMapping("/getYear")
    @ResponseBody
    public Object getYear(){
        List<Map> data = service.getYear();
        Map zmap = new HashMap();
        zmap.put("options",data);
        System.out.println("options+++"+zmap);
        return zmap;
    }

    @RequestMapping("/update")
    @ResponseBody
    public Integer update(@RequestBody Map map){
        System.out.println(map+"ssssssss");
        int row=service.update(map);
        return row;
    }
    @RequestMapping("/add")
    @ResponseBody
    public Integer add(@RequestBody Map map){
        int row=service.add(map);
        return row;
    }
    @RequestMapping("del")
    @ResponseBody
    public Integer del(Integer id){
        //System.out.println(id);
        int row = service.del(id);
        return row;
    }
}
